<?php
    if (!defined('EXPONENT')) exit('');
    if (exponent_users_isAdmin() ||  exponent_permissions_check(array("administrate"),$loc))
    {

        $content=$db->selectObject('mailsystem_template','id='.$_REQUEST['id']);
        $content->name=$_REQUEST['_temp_name'];
        $content->dir=$_REQUEST['_temp_dir'];
        $content->description=$_REQUEST['_temp_description'];
        $content->group=$_REQUEST['_temp_group'];
        $content->content=$_REQUEST['_temp_content'];
        $content->support_file=intval($_REQUEST['_temp_support_file']);
        $content->support_param=intval($_REQUEST['_temp_support_param']);

        if (!$content->id)
        { 
            $content->date=time();   
            $db->insertObject($content,'mailsystem_template');     
        }
        else
        {
            $db->updateObject($content,'mailsystem_template',"id='".$content->id."'"); 
        }
        
        header("Location: /index.php?module=mailsystemmodule&action=templates_manage");
        
    }
    else
        echo exponent_http_error(403);

?>
